package System_code;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-07-31
 * Time: 21:36
 */
public class Demo11 {
    private static Thread t1 = null;
    private static Thread t2 = null;
    public static void main(String[] args) throws InterruptedException {
        System.out.println("main begin");
        t1=new Thread(()->{
            System.out.println("t1 begin");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            while(true){
                System.out.println("t1 end");
            }
        });
        t1.start();
        t1.join();//让t1先执行完
        t2=new Thread(()->{
            System.out.println("t2 begin");
            try {

                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t2 end");
        });
        t2.start();
        t2.join();//让t2执行完
        System.out.println("main end");
    }
}
